Game Mechanics
One thing I noticed on the Wanted Page was a topic on Game Mechanics, the user Primetime requesting how to do fundamental RPG things, like turn-based combat similar to Final Fantasy, and how to calculate damage, etc. This is a stub because I don't want to be the only one writing this. Let's add formulas that others can use as a basis for their RPG. I'm in the process of making an RPG with friends from school, so I'm willing to share what mathematic and game knowledge in this stub. Overview of an RPG RPG or Role-Playing Game is where you as the player takes the role of a character inside of a fictional story, determining how they level up, what dialog actions they take, and how you move the story along. A classic RPG, such as Final Fantasy, has monsters on one of the battle screen, and the party on the other side. Ever since FFII, Square had implemented ATB combat, Action-Time-Based. This was how quickly characters would act depended on their Speed. In FFIV, the bar was invisible, but in FFVI, the bar was visible. When this bar filled up, the character would flash, and a menu would appear. Then the player could input the commands. RPGs have all types of attacks, usually divided into physical and magical, so just as common they have similar character stats like Physical Attack and Defense, and Magic Attack and Defense. The Character Class in an RPG Creating a class for the character is recommended, because you can hold all of the character's stats inside of the class. Also, you can have private subroutines to determine how HP and other stats are calculated based off of items and attributes. Class Hero Dim Strength as Integer Dim Intellect as Integer Dim Agility as Integer Dim HitPoints as Integer Dim Attack as Integer Here we can see the basic attributes of a hero. How strong he is, how smart he is, how fast he is, how much he can take, and how much he can dish out. It is possible to code an RPG with just these elements, but we're forgetting about other factors that take place inside of an RPG, such as: # Dodging # Critcals # Magic Attack and Defense But we can attack this later. Turn-Based Action Since the RPG I'm coding is a one-man-against-all, I'm only going to code for one character. This routine can be duplicated for multiple characters, and you can queue whose turn it is. Private Sub Encounter(ByVal Hero.Agility, ByVal Monster.Agility) Dim Roll as New Random If Hero.Agility + Roll.Next(-6,7) > Monster.Agility Call PartyTurn Else Call EnemyTurn End If End Sub Private Sub EnemyTurn() Finished = False 'Execute the AI or just have the monster do a basic attack 'After the monster has done it's attack, then set a boolean Finished to true If Finished = True Call PartyTurn EndIf End Sub Private Sub PartyTurn() Finished = False CombatMenu.Show Select Case CombatMenu.SelectedAction Case "Fight" Damage = Hero.Attack - Monster.Defense If Roll.Next(1,101) < Monster.DodgeChance LabelDamage.Text = "Miss" Damage = 0 Else LabelDamage.Text = Damage Monster.HitPoints = Monster.HitPoints - Damage EndIf Case "Spell" SpellMenu.Show 'going to end that there for now Case "Defend" Hero.Defense = Hero.Defense * 1.5 Case "Item" ItemMenu.Show 'Same with spell End Select Finished = True If Finished = True Call Monster.Turn End If End Sub At the beginning, when there is an encounter, the Random will pick numbers between -6 and 6 and add it to the player's Agility. This will create more dynamic situations, where sometimes the monster will go first, and other times the player will go first. It balances the playing field so slower, more powerful knights clad in armor or old, vulnerable wizards can get the first go if they get a positive, and a speedy thief can be caught off-guard, and thus lose any superior agility bonuses from that random. So because at the end of each subroutine it calls the other subroutine, then it will go back and forth. When either side does an action, it sets the boolean Finished to true, then calls the other team's subroutine.